Skip to content

Feat: Add no-member-access rule #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jul 3, 2025
Merged

Conversation

xpirad
Copy link
Contributor

@xpirad xpirad commented Jun 3, 2025

This pull request introduces a new ESLint rule for optimizing repeated member access patterns in AssemblyScript code. The rule aims to improve performance, readability, and maintainability by suggesting the extraction of frequently accessed member chains into variables. Additionally, the pull request includes updates to documentation, plugin configuration, and test cases to support and validate the new rule.

New ESLint Rule: no-repeated-member-access

  • Implementation of Rule:

    • Added the no-repeated-member-access rule in plugins/rules/memberAccess.ts. This rule identifies repeated member access patterns and suggests extracting them into variables for better performance and readability. It avoids warning for computed properties, array indices, or properties modified within the scope.
    • Added the rule to the ESLint plugin configuration in plugins/perfPlugin.ts.
  • Documentation:

    • Created a detailed guide for the no-repeated-member-access rule in docs/rules/no-repeated-member-access.md. This includes rule details, options, examples (correct and incorrect usage), and related rules.

Testing Enhancements

  • Test Suite for New Rule:
    • Added comprehensive test cases for the no-repeated-member-access rule in tests/rules/noRepeatedMemberAccess.test.ts. These cover valid scenarios, invalid scenarios, and edge cases to ensure the rule behaves as expected.
    • Updated the test suite configuration in tests/perfPlugin.test.ts to include the new rule's tests.

@xpirad xpirad marked this pull request as draft June 17, 2025 06:01
@xpirad xpirad marked this pull request as draft June 17, 2025 06:01
@xpirad xpirad marked this pull request as ready for review June 17, 2025 08:07
@xpirad xpirad marked this pull request as draft June 19, 2025 09:24
Changqing-JING
Changqing-JING previously approved these changes Jul 1, 2025
@xpirad xpirad marked this pull request as ready for review July 1, 2025 05:40
@Changqing-JING Changqing-JING merged commit 0debd21 into wasm-ecosystem:main Jul 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants